package com.example.kangjujiaofei.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@Slf4j
@RequestMapping("/jiaofeiApp")
public class HtmlController {

    //授权后跳转地址，传入用户多个手机号和openid
    @GetMapping("/index")
    public String index(Model model,@RequestParam(value = "phone") String phone,@RequestParam(value = "openid") String openid){
        model.addAttribute("phone",phone);
        model.addAttribute("openid",openid);
        return "index";
    }


    @GetMapping("/justPay")
    public String justPay(Model model,@RequestParam(value = "contractNo") String contractNo,
                        @RequestParam(value = "houseId") String houseId,
                        @RequestParam(value = "userId",required = false) String[] userId){
//        model.addAttribute("contractNo",contractNo);
//        model.addAttribute("houseId",houseId);
        return "redirect:https://kangju.0577tx.com/api/wechat/auth?contractNo="+contractNo+"&houseId="+houseId;
    }

 //分享支付用,传入订单好，房号等
    @GetMapping("/justPayHtml")
    public String justPayHtml(Model model,@RequestParam(value = "contractNo") String contractNo,
                        @RequestParam(value = "houseId") String houseId,
                        @RequestParam(value = "openid") String openid,
                        @RequestParam(value = "userId",required = false) String[] userId){
        model.addAttribute("contractNo",contractNo);
        model.addAttribute("openid",openid);
        model.addAttribute("houseId",houseId);
        return "detail";
    }

    @GetMapping("/detail")
    public String detail(Model model){
//        model.addAttribute("contractNo",contractNo);
//        model.addAttribute("openid",openid);
//        model.addAttribute("houseId",houseId);
        return "detail";
    }
}
